<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        body {
            text-align: center;
        }

        table {
            width: 90%;
            height: 200px;
            margin: auto;
        }

        th {
            background-color: pink;

        }
    </style>
</head>

<body>
    <table border="1" cellspacing="0" cellpading="1">
        <caption>
            <h1>学生列表</h1>
        </caption>
          <tr>
            <th>序号</th>
            <th>姓名</th>
            <th>年龄</th>
            <th>性别</th>
            <th>家乡</th>
        </tr>
      


        <script>
            let student = [
                { name: '小明', age: 18, sex: '男', address: '河北省' },
                { name: '小红', age: 19, sex: '女', address: '河南省' },
                { name: '小刚', age: 17, sex: '男', address: '陕西省' },
                { name: '小丽', age: 20, sex: '女', address: '江西省' }
            ]
            for (let i = 0; i < student.length; i++) {
             document.write(`
            <tr>
                <td>${i + 1}</td>
                 <td>${student[i].name}</td>
                  <td>${student[i].age}</td>
                   <td>${student[i].sex}</td>
                    <td>${student[i].address}</td>
            </tr>
            
            `)
            }

        </script>
    </table>

</body>

</html>